import React from 'react';
import ReactDOM from 'react-dom';
import Child from './child'
// A 中使用了 B  那么 A是父组件  B是子组件
// 组件上的事件或者属性 都是创造这个组件的人自己定义的
class App extends React.Component {
  state = {
    name: "珠峰"
  }
  change = (e) => {
    this.setState({
      name: e.target.value
    })
  }
  init = (name) => {
    this.setState({
      name: name
    })
    console.log(this.ccc)
  }
  render() {
    return <div className=''>
      <input type="text" value={this.state.name} onChange={this.change} />
      <h1>父组件</h1>
      <Child qqq={this.state.name} onWww={this.init} ref={el => this.ccc = el}>
        <h3>hello</h3>
        <b>wolrd</b>
        <div>666</div>
      </Child>
    </div>;
  }
}

ReactDOM.render(<App />, document.getElementById('root'))